﻿using System;
using System.Data;
using System.Collections.Generic;
using DataLib.Common;
using DataLib.Model;

namespace DataLib.BLL
{
	/// <summary>
	/// OutStorage
	/// </summary>
	public partial class OutStorage
	{

		#region  ExtensionMethod
        /// <summary>
        /// 出库编号是否已经使用
        /// </summary>
        /// <param name="strno">出库编号</param>
        /// <returns></returns>
        public bool isOutNo(string strno)
        {
            bool flag = false;
            DataTable dt = GetList("outStorageNo='" + strno + "'").Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                flag = true;
            }
            return flag;
        }

        public object GetWaitInStorage(string where)
        {
            return dal.GetWaitInStorage(where);
        }

        /// <summary>
        /// 出库查询
        /// </summary>
        /// <param name="@Belong">归属地</param>
        /// <param name="@LoadNum">虚拟Load </param>
        /// <param name="@outNo">出库单号</param>
        /// <param name="@Graphic">处理地</param>
        /// <param name="@goodsCode">--物品编码</param>
        /// <param name="@StartDate">出库时间起</param>
        /// <param name="@EndDate">出库时间止 </param>
        /// <param name="@barvalue">条码号</param>
        /// <param name="@conman">领料人</param>
        /// <param name="@BoxID">-箱号（货盘号）</param>
        /// <param name="@cum">客户</param>
        /// <param name="@outType">--出库方式 2出库分类  1出库拆解 3出库生产 4 出库销售  5移库出库 0无此条件</param>
        /// <returns></returns>
        public DataTable getDtByUnionWhere(string Belong,
                    string LoadNum,
                    string outNo,
                    string Graphic,
                    string goodsCode,
                    string StartDate,
                    string EndDate,
                    string barvalue,
                    string conman,
                    string BoxID,
                    string cum,
                    string outtype,
                    string goodsname,
                    string storageno)
        {
            if (EndDate.Trim() != "")
            {
                DateTime temp = DateTime.Parse(EndDate);
                temp = temp.AddDays(1).AddSeconds(-1);
                EndDate = temp.ToString();
            }
            return dal.getDtByUnionWhere(Belong, LoadNum, outNo, Graphic, goodsCode, StartDate, EndDate, barvalue, conman, BoxID, cum, outtype, goodsname, storageno);
        }

        /// <summary>
        /// 验证将要出库的BarCode是否合法
        /// </summary>
        /// <param name="barcodevalue"></param>
        /// <param name="outType"></param>
        /// <param name="returnvalue"></param>
        /// <returns></returns>
        public Model.BarCode OutBarCodeConfirm(string barcodevalue, string outType,string vload, ref string returnvalue)
        {
            return dal.OutBarCodeConfirm(barcodevalue, outType,vload, ref returnvalue);
        }


        /// <summary>
        /// 出库提交事件
        /// </summary>
        /// <param name="model">OutStorage的实例对象</param>
        /// <param name="strarr">需要出库的BarCode列表</param>
        /// <returns></returns>
        public int OutStorageSubmit(Model.OutStorage model, string strarr)
        {
            return dal.OutStorageSubmit(model, strarr);
        }


             /// <summary>
        /// 盘库出库提交事件
        /// </summary>
        /// <param name="model">OutStorage的实例对象</param>
        /// <param name="strarr">需要出库的BarCode列表</param>
        /// <returns></returns>
        public int PDOutStorageSubmit(Model.OutStorage model, string strarr)
        {
            return dal.PDOutStorageSubmit(model, strarr);
        }

        /// <summary>
        /// 出库条码删除事件
        /// </summary>
        /// <param name="barvalue">条码号</param>
        /// <param name="username">操作人员</param>
        /// <param name="outid">出库单ID</param>
        /// <returns></returns>
        public int DelBarOut(string barvalue, string username, string outid)
        {
            return dal.DelBarOut(barvalue, username, outid);
        }


        /// <summary>
        /// 计算barcode已入库的重量
        /// </summary>
        /// <returns></returns>
        public decimal GetInNwtByOutid(string outid)
        {
            return dal.GetInNwtByOutid(outid);
        }

        
        /// <summary>
        /// 出库修改提交事件
        /// </summary>
        /// <param name="model">OutStorage的实例对象</param>
        /// <param name="strarr">需要出库的BarCode列表</param>
        /// <returns></returns>
        public int OutStorageUpdate(Model.OutStorage model, string strarr)
        {
            return dal.OutStorageUpdate(model, strarr);
        }

        
        /// <summary>
        /// 返回出库盘点ID
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int InsertPDNo(string bcity, string gcity, string operman,string memo)
        {
            return dal.InsertPDNo(bcity, gcity, operman,memo);
        }

        
        /// <summary>
        /// 盘库出库列表
        /// </summary>
        /// <param name="city">处理地</param>
        /// <param name="status">7为待出库，8为待入库</param>
        /// <returns></returns>
        public DataTable GetPDOutsList(string city, string status)
        {
            return dal.GetPDOutsList(city, status);
        }

        
        /// <summary>
        /// 盘库入库维护列表
        /// </summary>
        /// <param name="city">处理地</param>
        /// <returns></returns>
        public DataTable GetPDInsUpdateList(string city)
        {
            return dal.GetPDInsUpdateList(city);
        }


        public DataTable GetOutStorageListStore(string bcity, string gcity, int currpage, int length, out int totalcount,
                                                string search)
        {
            return dal.GetOutStorageListStore(bcity, gcity, currpage, length, out totalcount, search);
        }

		#endregion  ExtensionMethod




    }
}

